#include "sprite.h"
#include "graphics.h"
#include "globals.h"

Sprite::Sprite()
{

}

Sprite::Sprite(Graphics &G, const std::string &FilePath, int SourceX, int SourceY, int Width, int Height, float PosX, float PosY)
{
	this->X = PosX;
	this->Y = PosY;
	this->SourceRect.x = SourceX;
	this->SourceRect.y = SourceY;
	this->SourceRect.w = Width;
	this->SourceRect.h = Height;
	this->Center = SDL_Point();
	Center.x = Width / 2;
	Center.y = Height / 2;
	this->Angle = 0;
	this->Tex = SDL_CreateTextureFromSurface(G.GetRenderer(), G.LoadImage(FilePath));
	if (this->Tex == NULL)
	{
		printf("Error: Unable to load image");
	}
}

Sprite::~Sprite()
{

}


void Sprite::Draw(Graphics &G, SDL_RendererFlip SRL)
{
	SDL_Rect DestinationRectangle = {X, Y, this->SourceRect.w * Globals::SPRITE_SCALE, this->SourceRect.h * Globals::SPRITE_SCALE};
	G.BlitSurface(this->Tex, &this->SourceRect, &DestinationRectangle, Angle, &Center, SRL);
}

void Sprite::Update()
{
	//Animation data will most likely go here
}